package com.atguigu.springcloud.controller;

import com.atguigu.springcloud.service.PaymentService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author Tu
 * @date 2023/6/11 18:27
 */
@Slf4j
@RestController
@RequestMapping("/api/v1")
public class PaymentController {

    @Resource
    private PaymentService paymentService;

    @Value("${server.port}")
    private String serverPort;

    @GetMapping("/payment/hystrix/ok/{id}")
    public String paymentInfoSuccess(@PathVariable Integer id) {
        String result = paymentService.paymentInfoSuccess(id);
        log.info("successResult：" + result);
        return result;
    }

    @GetMapping("/payment/hystrix/error/{id}")
    public String paymentInfoError(@PathVariable Integer id) {
        String result = paymentService.paymentInfoError(id);
        log.info("successResult：" + result);
        return result;
    }

    @GetMapping("/payment/hystrix/circuitBreaker/{id}")
    public String paymentCircuitBreaker(@PathVariable Integer id) {
        String result = paymentService.paymentCircuitBreaker(id);
        log.info("successResult：" + result);
        return result;
    }

}
